<?php
defined('_JEXEC') or die;

// disable core styles to avoid bs conflict
OC_Util::$core_styles = array();
disableIECache();

if(isDevMode()) {
   OCP\Util::addStyle('jobseeker', 'jobseeker');
   OCP\Util::addScript('jobseeker', 'home');
} else {
   OCP\Util::addStyle('static', 'jobseeker');
   OCP\Util::addScript('static', 'apps/jobseeker.home.min');
}
$lang = PFactory::getLanguage();
$lang->load("com_jobs", JPATH_SITE, "zh-CN");
OCP\App::setActiveNavigationEntry('jobseeker_index');

$addtips = false;
$haskonw_compete = JRequest::getString('haskonw_compete', null, 'cookie');
?>
<script type="text/javascript" src="<?php print_unescaped(OC_Helper::linkTo('jobseeker/js', 'jobseeker.php'));?>"></script>
 <div id="jobneeds" class="hr_position_set">
   <?php if(!empty($_['needjobs'])) :?>
   <?php $i=0; ?>
   <?php foreach($_['needjobs'] as $item): ?>
   <div class="hr_position_each <?php echo $i%2!=0 ? 'hr_position_each_havebg' : ''; ?> clearfix">
      <div class="hr_position_infoshow ">
         <dl>
            <dd><b><a href="javascript:;" class="showpositiondetail" data="{'jobid':<?=$item->id?>}"><?php echo $item->job_title; ?></a></b><?php echo ($item->is_new) ? '' : '<span class="yellowtext"><i class="i_speaker"></i> HR已查看简历</span>'; ?></dd>
         </dl>
         
         <div class="interview">
            <b class="black">应聘进度：</b>
            <?php 
               $isInviteToken = !empty($item->token) && ($item->auto_invite || !$item->auto_send) ? true : false;
               $requirements = json_decode($item->online_interview_requirements); 
               $progress = json_decode($item->online_interview_progress);
            ?>                               
            <?php if(isset($progress->interview)&&($progress->interview > 0)):?>
                     <span class='progress_ok'>完善信息&nbsp;<i class='finish ok'></i></span>
            <?php elseif(!$item->token):?>
                     <span class='progress_notok' title='HR未发出竞聘邀请，不能完善信息'><em style="color:#999999; font-style:normal;">完善信息</em>&nbsp;<i class='finish'></i></span>
            <?php else:?> 
                     <span class='progress_notok'><a target='_blank' href='<?php echo OC_Helper::linkToRoute("interview_home", array('token'=>$item->token));?>'>完善信息&nbsp;<i class='finish'></i></a></span>
            <?php endif;?>                       
            <?php if(isset($requirements->onlinetest) && ($requirements->onlinetest == 1) && $isInviteToken) :?>
               <?php echo "<span class='gray_arrow'></span>"; ?>
               <?php if(isset($progress->onlinetest) && ($progress->onlinetest > 0)):?>
                        <span class='progress_ok'>线上笔试&nbsp;<i class='finish ok'></i></span>
               <?php elseif(!$item->token):?> 
                        <span class='progress_notok' title='HR未发出竞聘邀请，不能线上笔试'><em style="color:#999999; font-style:normal;">线上笔试</em>&nbsp;<i class='finish'></i></span> 
               <?php else:?>
                        <span class='progress_notok'><a target='_blank' href='<?php echo OC_Helper::linkToRoute("interview_home", array('token'=>$item->token));?>'>线上笔试&nbsp;<i class='finish'></i></a></span>        
               <?php endif;?>         
            <?php endif; ?>
            
            <?php if(0): ?>
               <span class='gray_arrow'></span>
               <span class='progress_notok'><a href='#'>视频面试&nbsp;<i class='finish'></i></a></span>
            <?php endif; ?>
            
            <?php if(!empty($item->persontitle) && $isInviteToken) :?>
               <?php echo "<span class='gray_arrow'></span>"; ?>
               <?php 
               if(isset($progress->persontest) && ($progress->persontest > 0) && $item->date_diff<=90) {                 
                  echo" <span id='persontest_finished'><a class='lookresult_btn_a' href='javascript:;' data-id='".$item->sheetid."'><span class='haveposition progress_ok'>性格评测&nbsp;<i class='finish ok'></i></span></a></span>";
               }else{
                  echo "<span class='haveposition progress_notok'><a target='_blank' href='".OC_Helper::linkToRoute("persontest_home", array('jobid'=>$item->id))."'>性格评测&nbsp;<i class='finish'></i></a>";
                   }
              if(0){                
                 if(!empty($item->personcreated)){
                    echo "<span class='haveposition progress_notok'><a class='persontest_tip_button' href='javascript:;'>性格评测&nbsp;<i class='finish'></i></a>
                            <div class='hr_persontest_tipbox' style='display:none;' tabindex='-1'>
               	             <div class='hr_persontest_tip'>
                  	           <div class='hr_topmatch'>
                                   <div class='hr_topuppoint'></div>
                     	          <div>您已于".JHtml::_('date',$item->personcreated, 'Y-m-d H:i:s')."做过".$item->persontitle."，是否使用上次结果？</div>
                     	          <div style='margin-top:5px;'><button data=\"{'persontestedid': '".$item->testedid."','jobid': '".$item->id."'}\" class='btn btn-info btn-small replace_button' style='margin-right:12px'>使用</button> <a target='_blank' href='".OC_Helper::linkToRoute("persontest_home", array('jobid'=>$item->id))."'>重新评测</a><span class='error server'></span></div>
                                </div>
                               </div>
                              </div>
                           </span>";
                    } 
                }              
               ?>
            <?php endif; ?>
         </div>
         
         <dl>   
            <dd class="medium">
               <a target="_blank" href="<?php echo OC_Helper::linkToRoute("company_preview", array('sub_domain'=>$item->employer_id)); ?>"><?php echo $item->comp_name; ?></a> <span>|</span>
               工作地区：<?php echo ($item->state || $item->city) ? ($item->state == $item->city ? $item->state : $item->state.' '.$item->city) : '不限'; ?> <span>|</span>
               工作职能：<?php echo $item->position ? $item->position : '未设置'; ?> <span>|</span>
               薪水：<?php echo $item->salary_type ? JText::_($item->salary_type) : '不限' ; ?> <span>|</span>
               经验：<?php echo $item->exp_name ? JText::_($item->exp_name) : '不限' ; ?> <span>|</span>
               人数：<?php echo $item->num_needed ? $item->num_needed : '若干'; ?>
            </dd>
         </dl>
         
         <div class="jobseeker_compete">
            <span><?php echo (empty($progress->interview) && $item->match_degree<=0) ? "<em style='color:#999999;'>--</em>" : $item->match_degree ; ?></span><br/><em>竞争力指数</em>
            <?php if(!$addtips && !$haskonw_compete && empty($progress->interview)): ?>
            <div class="compete_tips medium songti iknowtext">您尚未开始线上竞聘，无法分析竞争力。
               <?php if($item->token):?>
                  <a target="_blank" href="<?php echo OC_Helper::linkToRoute("interview_home", array('token'=>$item->token)) ?>"><b>马上开始>></b></a> 
               <?php endif; ?>
               <a href="javascript:;" data-cookie="7" data-cookiename="haskonw_compete" class="iknow know_compete">我知道了</a></div>
            <?php $addtips = true; ?>
            <?php endif; ?>
         </div>
      </div>
    
   </div>
   <?php $i++; ?>
   <?php endforeach; ?>
   <?php else: ?>
   <div class="hr_position_nodata">
      <div class="hr_netaddress">
         <span class="nodata_tip yahei large">暂无您的职位信息</span>
      </div>
   </div>
   <?php endif; ?>
 </div>
<div class="modal hide fade jobseekerlookposition" id="jobseekerlookposition">
   <div class="modal-header">
      <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
      <h3>职位详情</h3>
   </div>
   <div class="modal-body">
   </div>
</div>
<div class="modal hide fade resultpersontest_dialog" id="resultpersontest_dialog">
</div>
